package com.punai.monthanalysis.controller;

import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.domain.BaseEntity;
import com.punai.externalccb.service.IYdCbfeeiteminfoStandardService;
import com.punai.monthanalysis.bo.ProjectMonthInfoBo;
import com.punai.monthanalysis.bo.TableAndGraphDataBo;
import com.punai.monthanalysis.service.YdSummaryHzService;
import com.punai.monthanalysis.vo.SummaryVo;
import com.punai.monthanalysis.vo.TableListVo;
import com.punai.prodatalibrary.domain.LibProjectInfo;
import com.punai.prodatalibrary.service.ILibProjectInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/costData/monthanalysis")
public class MonthCostAnalysisController extends BaseController {

    @Autowired
    private ILibProjectInfoService libProjectInfoService;

    @Autowired
    private YdSummaryHzService ydSummaryHzService;

    @Autowired
    private IYdCbfeeiteminfoStandardService ydCbfeeiteminfoStandardService;


    @GetMapping("getTableAndGraphData")
    public AjaxResult getTableAndGraphData(SummaryVo vo) {
        TableAndGraphDataBo tableAndGraphDataBo = ydSummaryHzService.selectTableAndGraphData(vo);
        return AjaxResult.success(tableAndGraphDataBo);
    }


    @GetMapping("getTableList")
    public AjaxResult getKLMonthData(TableListVo vo) {
        LibProjectInfo libProjectInfo = libProjectInfoService.selectLibProjectInfoById(vo.getInfoId());
        List<? extends BaseEntity> tabsDataList = ydCbfeeiteminfoStandardService.getTabsDataList(libProjectInfo.getProId(), vo);
//        ProYdcbfxTabsService bean = SpringUtils.getBean(YdcbfxConstants.TABS_TYPE.getActuator(vo.getType()));
//        List<? extends BaseEntity> tabsDataList1 = bean.getTabsDataList(libProjectInfo.getProId());
        return AjaxResult.success(tabsDataList);
    }

    @GetMapping("getCbkhsjfxbInfo")
    public AjaxResult getCbkhsjfxbInfo(String infoId,String monthId){
        LibProjectInfo libProjectInfo = libProjectInfoService.selectLibProjectInfoById(infoId);
        ProjectMonthInfoBo infoBo = ydSummaryHzService.getCbkhsjfxbInfo(libProjectInfo,monthId);
        return AjaxResult.success(infoBo);
    }

    @GetMapping("getMonthProjectInfo")
    public AjaxResult getProjectMonthInfo(String infoId,String monthId,String type){
        LibProjectInfo libProjectInfo = libProjectInfoService.selectLibProjectInfoById(infoId);
        ProjectMonthInfoBo infoBo = ydSummaryHzService.getProjectMonthInfo(libProjectInfo.getProId(),monthId,type);
        return AjaxResult.success(infoBo);
    }



}
